/*
 * Classname: OperatorDaoImpl.java
 * 
 * Version information
 *
 * Date: 2007-6-28
 * 
 * Copyright DMX
 */
package com.dmx.fw.dao.hibernateimpl;

import java.util.List;
import com.dmx.fw.bean.mapping.pojo.CacheCode;
import com.dmx.fw.bean.mapping.pojo.ParameterData;
import com.dmx.fw.bean.mapping.pojo.Role;
import com.dmx.fw.dao.hibernateimpl.BaseDaoImpl;
import com.dmx.fw.dao.interfaces.CacheCodeDao;
/**
 * Description: Operator Dao Implementation.
 * 
 * @author Peter Wei
 * @version 1.0 2007-6-28
 */
public class CacheCodeDaoImpl extends BaseDaoImpl implements CacheCodeDao {
	/**
	 * 取得“是、否”下拉框的内容
	 * @param 
	 * @return
	 */
	public List getIsCacheList() {
		String hql = "from ParameterData where TYPE_CODE='SELECT_YESNO' and STATUS='1'";
		return getHibernateTemplate().find(hql);
	}
	/**
	 * 取得“是、否”
	 * @param 
	 * @return
	 */
	public String getIsCacheTextByCode(String code) {
		String hql = "from ParameterData where TYPE_CODE='SELECT_YESNO' and STATUS='1' and code=?";
		List tmp = (List)getHibernateTemplate().find(hql ,code);
		return tmp==null||tmp.isEmpty()?"":((ParameterData)tmp.get(0)).getName();
	}
	/**
	 * 根据ID取得一个Cache Code
	 * @param 
	 * @return
	 */
	public CacheCode getOneCacheCode(Long id) {
		return (CacheCode)getHibernateTemplate().get(CacheCode.class, id);
	}
	/**
	 * 根据code取得Cache Code
	 * @param 
	 * @return
	 */
	public List findCacheCode(CacheCode cacheCode) {
		String hql = "from CacheCode where code=?";
		Object[] temp = {cacheCode.getCode()};
		return getHibernateTemplate().find(hql, temp);
	}
}
